﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace IRM.Messaging
{
    public enum HandleResult
    {
        Success,
        NotHandled,
        ScheduleForRetry
    }

    public interface IMessageHandler
    {
        /// <summary>
        /// 
        /// </summary>
        /// <param name="message"></param>
        /// <returns></returns>
        /// <remarks>The handler can be called multiple times with the same message so it is the responsibility 
        /// of the handler to ensure that the messages are idempotent.</remarks>
        HandleResult Handle(Message message);

        /// <summary>
        /// The exception representing the reason to why the handler needs to retry.
        /// </summary>
        /// <remarks>
        /// This property must return an <see cref="Exception"/> when <see cref="Handle"/> returns <see cref="HandleResult.ScheduleForRetry"/>.
        /// </remarks>
        Exception RetryException { get; }
    }
}
